home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf
/
XLisp-Stat
/
menubar.lsp
< prev
next >
Wrap
Lisp/Scheme
|
1990-06-01
|
3KB
|
91 lines
;;;;
;;;;
;;;; menubar.lsp Menus for the Amiga
;;;; XLISP-STAT 2.0 Copyright (c) 1988, by Luke Tierney
;;;; All Rights Reserved
;;;; Permission is granted for unrestricted non-commercial use
;;;; Additions to
;;;; Xlisp 2.0 Copyright (c) 1985, 1987 by David Michael Betz
;;;;
;;;;
(provide "menubar")
;;;;
;;;; General Menu Methods and Functions
;;;;
(defmeth menu-proto :find-item (str)
"Method args: (str)
Finds and returns menu item with title STR."
(dolist (item (send self :items))
(if (string-equal str (send item :title)) (return item))))
(defun find-menu (title)
"Args: (title)
Finds and returns menu in the menu bar with title TITLE."
(dolist (i *hardware-objects*)
(let ((object (nth 2 i)))
(if (and (kind-of-p object menu-proto)
(send object :installed-p)
(string-equal (string title) (send object :title)))
(return object)))))
(defun set-menu-bar (menus)
"Args (menus)
Makes the list MENUS the current menu bar."
(dolist (i *hardware-objects*)
(let ((object (nth 2 i)))
(if (kind-of-p object menu-proto) (send object :remove))))
(dolist (i menus) (send i :allocate) (send i :install)))
;;;;
;;;; File Menu
;;;;
(defvar *file-menu* (send menu-proto :new "File"))
(defproto file-edit-item-proto '(message) '() menu-item-proto)
(defmeth file-edit-item-proto :isnew (title message &rest args)
(setf (slot-value 'message) message)
(apply #'call-next-method title args))
(defmeth file-edit-item-proto :do-action ()
(send (front-window) (slot-value 'message)))
(defmeth file-edit-item-proto :update ()
(send self :enabled (kind-of-p (front-window) edit-window-proto)))
(send *file-menu* :append-items
(send menu-item-proto :new "Load" :key #\L :action
#'(lambda ()
(let ((f (open-file-dialog t)))
(when f (load f) (format t "; finished loading ~s~%" f)))))
(send dash-item-proto :new)
(send menu-item-proto :new "Quit" :key #\Q :action 'exit))
;;;;
;;;; Command Menu
;;;;
(defvar *command-menu* (send menu-proto :new "Command"))
(send *command-menu* :append-items
(send menu-item-proto :new "Clean Up" :key #\, :action #'clean-up)
(send menu-item-proto :new "Toplevel" :key #\. :action #'top-level)
(send dash-item-proto :new)
(let ((item (send menu-item-proto :new "Dribble" :key #\D)))
(send item :action
#'(lambda ()
(cond
((send item :mark) (dribble) (send item :mark nil))
(t (let ((f (set-file-dialog "Dribble file:")))
(when f
(dribble f)
(send item :mark t)))))))
item))
(defconstant *standard-menu-bar* (list *file-menu* *command-menu*))
(set-menu-bar *standard-menu-bar*)